package com.xiaohudie.Lambda;

/**
 * @Author xiao hu die
 * @Date 2022/1/16 17:27
 * @Version 1.0
 */

import org.junit.jupiter.api.Test;

import java.util.Comparator;

/**lambda表达式的测试*/
public class Lambda01 {
    public static void main(String[] args) {
        Runnable runnable = new Runnable(){

            @Override
            public void run() {
                System.out.println("我喜欢你刘碟");
            }
        };
        runnable.run();
        System.err.println("################");
     Runnable runnable1 =  ()-> System.out.println("我喜欢你陈唯一");

     runnable1.run();

    }
    @Test
    public void test01(){
        Comparator<Integer> comparable =new Comparator<Integer>(){
            @Override
            public int compare(Integer o1, Integer o2) {
                return Integer.compare(o1,o2);
            }
        };
        int i = comparable.compare(12, 26);
        System.out.println(i);
        System.out.println("&&&&&&&&&&&&&&&&&&&&&");
        /**Lambda表达式*/
        Comparator<Integer> comparator1  =(x,y)-> Integer.compare(x,y);
        int compare = comparator1.compare(25, 25);
        System.out.println(compare);
        /**方法引用*/
        Comparator<Integer> comparator = Integer::compare;
        int compare1 = comparator.compare(12, 0);
        System.out.println(compare1);
    }

}
